package com.hujf.mapreduce.partitioner2;

import com.hujf.mapreduce.partitioner2.FlowBean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author Hujf
 * @title: MyPartition
 * @date 2021/3/3116:44
 * @description: TODO
 */
public class MyPartition extends Partitioner<Text,FlowBean> {
    @Override
    public int getPartition(Text o, FlowBean o2, int numPartitions) {
        String phone =o.toString();
        //获取前3位
        String prePhone = phone.substring(0,3);

        int part;
        switch (prePhone){
            case "136":
                part=0;
                break;
            case "137":
                part=1;
                break;
            case "138":
                part=2;
                break;
            case "139":
                part=3;
                break;
            default:
                part=4;
        }
        return part;
    }
}
